package com.atguigu.daijia.driver.controller;

import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.driver.service.OcrService;
import com.atguigu.daijia.model.vo.driver.DriverLicenseOcrVo;
import com.atguigu.daijia.model.vo.driver.IdCardOcrVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Tag(name = "腾讯云识别接口管理")
@RestController
@RequestMapping(value = "/ocr")
@SuppressWarnings({"unchecked", "rawtypes"})
@RequiredArgsConstructor
public class OcrController {

    private final OcrService ocrService;

    /**
     * 上传身份证并进行 OCR 识别
     * @param file
     * @return
     */
    @Operation(summary = "上传身份证并进行 OCR 识别")
    // @GuiguLogin
    @PostMapping("/idCardOcr")
    public Result<IdCardOcrVo> uploadIdCardAndOcr(@RequestPart("file") MultipartFile file) {
        IdCardOcrVo idCardOcrVo = ocrService.uploadIdCardAndOcr(file);
        return Result.ok(idCardOcrVo);
    }

    /**
     * 上传驾驶证并进行 OCR 识别
     * @param file
     * @return
     */
    @Operation(summary = "上传驾驶证并进行 OCR 识别")
    // @GuiguLogin
    @PostMapping("/driverLicenseOcr")
    public Result<DriverLicenseOcrVo> uploadDriverLicenseAndOcr(@RequestPart("file") MultipartFile file) {
        DriverLicenseOcrVo driverLicenseOcrVo = ocrService.uploadDriverLicenseAndOcr(file);
        return Result.ok(driverLicenseOcrVo);
    }
}

